import { createApp } from "vue";
import { store } from "./store";
// normalize.css
import "normalize.css/normalize.css";
// 引入样式
import "./styles/index.ts";
// svg icon
import "virtual:svg-icons-register";

import App from "./App.vue";
import router from "./router";
// 引入指令
import directives from "@/directives";

const app = createApp(App);

// 动态设置 favicon（新增代码）
const setFavicon = () => {
  const favicon = document.querySelector('link[rel="icon"]');
  if (favicon) {
    // 如果已有 icon 配置，更新路径
    (favicon as HTMLLinkElement).href = "/logo.png";
  } else {
    // 如果没有，创建新的 link 标签
    const link = document.createElement("link");
    link.rel = "icon";
    link.href = "/logo.png"; // 指向 public 文件夹下的 favicon.ico
    document.head.appendChild(link);
  }
};

// 初始化时设置 favicon
setFavicon();

app.use(store);
app.use(router);
app.use(directives);

app.mount("#app");